package com.share.schedule.simple.service.impl;

import com.share.schedule.simple.dao.ScheduleJobMapper;
import com.share.schedule.simple.model.db.ScheduleJob;
import com.share.schedule.simple.model.db.ScheduleJobExample;
import com.share.schedule.simple.service.ScheduleJobService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

@Slf4j
@Service
public class ScheduleJobServiceImpl implements ScheduleJobService {
    @Resource
    private ScheduleJobMapper scheduleJobMapper;

    @Override
    public Map<String, ScheduleJob> mapAllTask() {
        Map<String, ScheduleJob> map = new HashMap<>();
        ScheduleJobExample example = new ScheduleJobExample();
        example.createCriteria().andJobStatusNotEqualTo(0);
        List<ScheduleJob> list = scheduleJobMapper.selectByExample(example);
        for (ScheduleJob record : list) {
            map.put(record.getJobCode(), record);
        }
        return map;
    }
}